package com.wangzhixuan.commons.enums;

import lombok.Getter;
import org.springframework.util.Assert;

import java.time.Duration;

/**
 * 缓存名称枚举
 *
 * @author lixin
 */
@Getter
public enum  CacheEnum {
    /**
     * 用户信息缓存名称
     */
    ACTIVE_SESSION_CACHE("activeSessionCache",Duration.ZERO),

    /**
     * 授权缓存名称
     */
    AUTHORIZATION_CACHE("authorizationCache",Duration.ZERO),

    /**
     * 权限认证缓存名称
     */
    AUTHENTICATION_CACHE("authenticationCache",Duration.ZERO),

    /**
     * 半小时缓存名称
     */
    HALF_HOUR("halfHour",Duration.ofMinutes(30)),

    /**
     * 一天缓存
     */
    ONE_DAY("oneDay",Duration.ofDays(1)),

    /**
     * 10分钟缓存名称
     */
    TEN_MINUTES("tenMinutes",Duration.ofMillis(10)),

    /**
     * 1小时缓存名称
     */
    HOUR("hour",Duration.ofHours(1)),

    /**
     * 验证码缓存名称
     */
    CAPTCHA_CACHE("captchaCache",Duration.ofMinutes(2));
    /**
     * 缓存名称
     */
    private String name;
    /**
     * 缓存失效时间，可为null
     */
    private Duration cacheTime;

    CacheEnum(String name, Duration cacheTime) {
        Assert.notNull(name, "cacheName must not be null!");
        this.name = name;
        this.cacheTime = cacheTime;
    }
}
